<!--
 * @Author: sbotlp
 * @Email: sbotlp@sina.com
 * @Date: 2019-11-30 18:05:01
 * @LastEditTime: 2019-12-01 15:50:03
 * @Description: http://www.sbotlp.com.cn
 -->
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <script src="'./invoke.js'"></script>
</head>
<body>
  schema test
  <button id="btn">扫一扫</button>
  <button id="btn1">分享</button>
  <script>
    /* function invokeScan() {
      // 定义全局函数，通过schema传参给客户端，让客户端去调用执行
      window['_invoke_scan'] = function(resolve) {
        console.log('resolve: ', resolve);
      }
      var iframe = document.createElement('iframe');
      iframe.style.display = 'none';
      iframe.src = 'weixin://dl/scan'; // 调用 schema 
      iframe.src = 'weixin://dl/scan?k1=v1&k2=v2&k3=v3&callback=_invoke_scan' // 带参数，回调，
      var body = document.body || document.getElementsByTagName('body')[0];
      body.appendChild(iframe);
        // 防止触发多次schema
      setTimeout(function() {
        body.removeChild(iframe);
        iframe = null;
      })
    }
    document.getElementById('btn').addEventListener('click', function() {
      invokeScan();
    }); */
    document.getElementById('btn').addEventListener('click', function() {
      window.invoke.invoke({}, function(){})
    });
    document.getElementById('btn1').addEventListener('click', function() {
      window.invoke.share({title: 'xxxx', content:'xxxxx'}, function(result){
        if (!result.onerror) {
          console.log('分享成功');
        }else {
          console.log(result.onerror);
        }
      })
    });
  </script>

</body>
</html>